import 'dart:ui';

class YSHSizeFit {
  // 1.基本信息
  static double physicalWidth = 0;
  static double physicalHeight = 0;
  static double devicePixelRatio = 0;
  static double screenWidth = 0;
  static double screenHeight = 0;
  static double statusBarHeight = 0;
  static double homeBarHeight = 0;
  static double rpx = 0;
  static double px = 0;

  static void initialize({double standardSize = 750}) {
    // 1.手机的物理分辨率
    physicalWidth = window.physicalSize.width;
    physicalHeight = window.physicalSize.height;

    // 2.获取dpr
    devicePixelRatio = window.devicePixelRatio;

    // 3.宽度和高度
    screenWidth = physicalWidth / devicePixelRatio;
    screenHeight = physicalHeight / devicePixelRatio;

    // 4.状态栏高度&homebar高度
    statusBarHeight = window.padding.top;
    homeBarHeight = window.padding.bottom;
    // 5.计算rpx的大小
    rpx = screenWidth / standardSize;
    px = rpx * 2;
  }

  static double setRpx(double size) {
    return rpx * size;
  }

  static double setPx(double size) {
    return px * size;
  }
}
